package com.macro.mall.portal.wxpay.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * 微信统一下单trade_type字段值
 */
@Getter
@AllArgsConstructor
public enum TradeTypeEnum {

    /**
     * APP支付
     */
    APP("APP", "app支付"),

    /**
     * H5支付
     */
    H5("MWEB", "H5支付"),

    JSAPI("JSAPI", "JSAPI支付");

    private String value;

    private String tradeType;

    public static TradeTypeEnum toType(String value) {
        return Stream.of(TradeTypeEnum.values())
                .filter(p -> p.tradeType.equals(value))
                .findAny()
                .orElse(null);
    }

}
